﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Navigation;
using Windows.Phone.PersonalInformation;
using BalanceManager.Helpers;
using BalanceManager.Model;
using BalanceManager.ViewModels;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace BalanceManager.Views
{
    public partial class AddFundFlow : BindablePage
    {
        public AddFundFlow()
        {
            InitializeComponent();
        }

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            var textBox = sender as TextBox;

            var decimalSeparator = textBox.Text.IndexOf('.');
            if (decimalSeparator != -1)
                textBox.SelectionStart = decimalSeparator;
            
            var bindingExpr = textBox.GetBindingExpression(TextBox.TextProperty);
            bindingExpr.UpdateSource();
        }

        private void TextBox_Hold(object sender, System.Windows.Input.GestureEventArgs e)
        {

        }

        private void TextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            var textBox = sender as TextBox;
            textBox.SelectAll();
        }
    }
}